/*
 * File:   Turtle.h
 * Author: Thomas Trojer
 *
 * Created on 02. Juli 2010, 22:37
 */

#ifndef TURTLE_H
#define TURTLE_H

#include "turtle/TurtleState.h"
#include "turtle/Watcher.h"
#include "turtle/RoutePlanner.h"

#include "types/Stack.h"
typedef Stack<Watcher*> WatcherStack;
#include "types/Vec3.h"
#include "types/Vec4.h"
#include "types/Mat4.h"
#include <string>

using mehari::common::Mat4f;
using mehari::common::Vec3f;
using mehari::common::Vec4f;
using std::string;

class Turtle {
public:
    Turtle(RoutePlanner& planner);
    Turtle(const Turtle& orig);
    virtual ~Turtle();

    const TurtleState* getState();

    RoutePlanner* getPlanner() const;

    void walk();
    void walk(float dist);
    void swim();
    void swim(float dist);
    void roll(float rad);
    void pitch(float rad);
    void rotate(float rad);
    void turn();
    void upright();

    void sleep();
    void wakeup();

    string feed(string meal);

    void watch(Watcher* watcher);

private:
    RoutePlanner* plan;

    TurtleState* trace;
    TurtleState* state;

    WatcherStack watchers;

    TurtleStack stack;

    // w is ignored in pos
    Vec4f pos;
    Vec4f dir;
    Vec4f up;

    void rotate(Vec4f& point, const Vec4f& axis, float angle) const;
};

#endif  /* TURTLE_H */
